package com.zybzzz.workapp.entry;

import android.widget.TextView;

import androidx.annotation.Nullable;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * 封装计划消息的实体类
 */
public class PlanMsg implements Serializable {
    //实现了Serializable可序列化接口，这保证在一定情境下这个类的对象实例可以被传输


    //标识一个计划的唯一id
    private UUID id;
    //计划的名称
    private String title;
    //计划的备注、详细说明
    private String remark;
    //这个属性暂时没有用到
    //private boolean isfinished;


    //熟悉项目：文件没有多大的修改 仅仅增加一个Integer保存整数
    //增加String类型的分子分母 供进度条使用


    //暂时添加两个list用作详细任务点信息的储存 设置Integer用作任务点数量
    private Integer taskTotalNum;   //总共的任务点数量
    //用于记录小任务点是否完成的boolean列表，它代表着完成按钮是否被选择
    private List<Boolean> taskFinisheds;
    //用于记录完成的任务点数
    private Integer finishedNum;
    //用于记录每个小任务
    private List<String> taskItems;
    //小计划的日期
    private List<String> taskDates;
    //小计划的时间
    private List<String> taskTimes;
    //分子
    private String finishNum;
    //分母
    private String totalNum;


    public PlanMsg(){

        id=UUID.randomUUID();
        title=new String();
        remark=new String();
        //isfinished=false;
        taskTotalNum=0;
        taskFinisheds=new ArrayList<>();
        taskItems=new ArrayList<>();
        taskDates=new ArrayList<>();
        taskTimes=new ArrayList<>();
        finishNum=new String();
        totalNum=new String();

    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public UUID getId() {
        return id;
    }

    public void setId(UUID id) {
        this.id = id;
    }

//    public boolean getIsfinished() {
//        return isfinished;
//    }
//
//    public void setIsfinished(boolean isfinished) {
//        this.isfinished = isfinished;
//    }


    public List<Boolean> getTaskFinisheds() {
        return taskFinisheds;
    }

    public void setTaskFinisheds(List<Boolean> taskFinisheds) {
        this.taskFinisheds = taskFinisheds;
    }

    public List<String> getTaskItems() {
        return taskItems;
    }

    public void setTaskItems(List<String> taskItems) {
        this.taskItems = taskItems;
    }

    public List<String> getTaskDates() {
        return taskDates;
    }

    public void setTaskDates(List<String> taskDates) {
        this.taskDates = taskDates;
    }

    public List<String> getTaskTimes() {
        return taskTimes;
    }

    public void setTaskTimes(List<String> taskTimes) {
        this.taskTimes = taskTimes;
    }

    public Integer getTaskTotalNum() {
        return taskTotalNum;
    }

    public void setTaskTotalNum(Integer taskTotalNum) {
        this.taskTotalNum = taskTotalNum;
    }


    /**
     * 重写的equals方法，后续在有添加操作的时候会先比较
     * 如果在容器中有的PlanMsg对象就不添加，没有的则进行添加
     * 容器即List<PlanMsg> 在PlanMsgLab类中
     * @param: [obj]
     * @return: boolean
     * @author: ZhangYiBo
     * @date: 2020/10/15
     */
    @Override
    public boolean equals(@Nullable Object obj) {
        if (obj instanceof PlanMsg){
            UUID anotherPlanId=((PlanMsg) obj).getId();
            return this.id.equals(anotherPlanId);
        }
        return false;
    }


    /**
     * @name: getNumberOfFinish
     * @description: 查看容器中有多少完成的任务
     * 直接循环遍历
     * @return: java.lang.Integer
     * @date: 2020-10-22 07:05
     * @auther: zhangyibo
     *
    */
    public Integer getNumberOfFinish(){
        int count=0;
        for (Boolean taskFinished : taskFinisheds) {
            if (taskFinished!=null&&taskFinished){
                ++count;
            }
        }
        return count;
    }
}
